package scheduler

import "crawler/engine"

type SimpleScheduler struct {
	workerChan chan engine.Request
}

func (s *SimpleScheduler) WorkerChan() chan engine.Request {
	return s.workerChan
}

func (s *SimpleScheduler) Run() {
	s.workerChan = make(chan engine.Request)
}

func (s *SimpleScheduler) WorkerReady(chan engine.Request) {
}

// 简单并发调度器
func (s *SimpleScheduler) Submit(r engine.Request) {
	// 发送request到worker Chanel
	// s.workerChan <- r 会卡死，因此为每个Request创建一个goroutine
	go func() {
		s.workerChan <- r
	}()
}
